<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/

//服务
namespace Shop\Controller;
use Think\Controller;
class FuwuController extends \Shop\Controller\IndexController {
	
	public function CheckTask(){
		$id=intval($_GET['id']);
		$this->assign('id',$id);
		$this->assign('uid',$this->uid);
		$this->assign('uploadid','sid'); //设置上传文件任务字段
		
		if($id){
			$upload=new \Upload\Model\FileModel();
			$data=new \Data\Model\DataModel();
			$manage=$data->GetData($id);

			if(empty($manage['id'])){
				$this->error($data->getError());
				return false;
			}
			
			if($manage['process']!=4){
				$this->error('该服务审核中','/fuwu');
				return false;
			}
			
			$data->UpdateData($manage['id']);
			
			$picfile=$upload->GetUploadFile('sid',$id);
			
			$this->assign('picfile',$picfile);
			
			$this->assign('fuwu',$manage);
			
			$uploadsize=round(C('onefileuploadsize')/1024/1024,2);
			$this->assign('uploadsize',$uploadsize);
			
			//相关4条数据
			$catid=intval($manage['catid']);
			$fuwuarray=$data->token(false)->where(" catid=$catid AND type=2 ")->order('dateline DESC')->limit(4)->select();
			$this->assign('fuwuarray',$fuwuarray);
		}
		
		return $manage;
	}
	
	public function indexAction(){

		$manage=$this->CheckTask();
		$this->GetShop($manage['uid']);
		
		$this->assign('SEO',array('title'=>'￥'.($manage['money']).'元 '.$manage['subject'],'keywords'=>$manage['subject'],'description'=>$manage['description']));
		
		$this->display();
	}
	
	public function listAction(){
		
		$shopuid=$this->GetShop();
		
		$pagenum=intval($_GET['p']);
		
		$wheresql=" type=2 AND uid=$shopuid AND process=4 ";
 
		//数据-------------------------------
		$list=M('Data')->token(false)->where($wheresql)->order('dateline DESC')->page($pagenum,20)->select();

		//页码-------------------------------
		$count=M('Data')->token(false)->where($wheresql)->count();
		$Page = new \Think\Page($count,20);
		
		$this->assign('list',$list);	
		$this->assign('page',str_replace("/m/shop",'',$Page->show()));
		
		$this->display();
	}
	
}